Example: Using the MQTT Client SL Library
Product: CODESYS IIOT Libraries SL
The MQTT Client SL Example.project
sample project, which includes a visualization to send and receive messages, shows how to use the MQTT Client SL library.
Setting up a Mosquitto MQTT broker on a Raspberry Pi
Command to install the Mosquitto broker:
sudo apt-get install mosquitto mosquitto-clients
Command to start and stop the service:
sudo service mosquitto start sudo service mosquitto stop
Commands for testing:
mosquitto_sub -d -V mqttv311 -t hello/world mosquitto_pub -d -V mqttv311 -t hello/world -m "Hello!"
Description
The MQTT Client SL Example.project
sample project shows how to use the function blocks and can be used for testing purposes. All inputs of the function blocks can be configured from the visualization. The example contains two subscribers and two publishers.
MQTT Client SL Example.project

System requirements and restrictions
Programming system | CODESYS Development System (version 3.5.18.0 or higher) |
Runtime system | CODESYS Control Win (version 3.5.18.0) |
Add-on components | MQTT broker |
Note
DOWNLOAD projects